package bavaria.hightech.banking.conditions;

import java.text.MessageFormat;
import java.text.NumberFormat;

import bavaria.hightech.banking.resourceBundles.LanguageBundle;

/**
 * this is the derivated class for giro conditions
 */
public class GiroConditions extends Conditions {

	private int overdraft;
	private int interest_is;

	/**
	 * default-constructor
	 * @param interest_have
	 * @param interest_is
	 * @param rating
	 * @param languageBundle
	 */
	public GiroConditions(int interest_have, int interest_is, int rating,
			LanguageBundle languageBundle) {
		this.interest_have = interest_have;
		this.overdraft = getOverdraftFromRating(rating);
		this.interest_is = interest_is;
		this.languageBundle = languageBundle;
	}

	/**
	 * get overdraft depends by param
	 * @param rating
	 * @return
	 */
	private int getOverdraftFromRating(int rating) {
		switch (rating) {
		case 1:
			return 1000;
		case 2:
			return 2000;
		case 3:
			return 3000;
		default:
			return 0;
		}
	}

	/**
	 * get overdraft
	 * @return
	 */
	public int getOverdraft() {
		return overdraft;
	}

	/**
	 * set overdraft by param
	 * @param overdraft
	 */
	public void setOverdraft(int overdraft) {
		this.overdraft = overdraft;
	}

	/**
	 * get interest is
	 * @return
	 */
	public int getInterest_Is() {
		return interest_is;
	}

	@Override
	public int getInterest_Have() {
		return interest_have;
	}

	/**
	 * set interest is by param
	 * @param interest_is
	 */
	public void setInterestIs(int interest_is) {
		this.interest_is = interest_is;
	}

	/**
	 * set interest have by param
	 * @param interest_have
	 */
	public void setInterestHave(int interest_have) {
		this.interest_have = interest_have;
	}

	@Override
	public String toString() {
		String str = "";
		String formattedOverdraft = NumberFormat.getNumberInstance(
				languageBundle.getLocale()).format(overdraft);
		str = "{6}:\n";
		str += "{8}: " + formattedOverdraft + "\n";
		str += "{9}: " + interest_is + "\n";
		str += "{10}: " + interest_have + "\n";
		str = MessageFormat.format(str, languageBundle.getContents());
		return str;
	}
}
